// pages/aftersale/servicetype.js
import Router from '../../utils/router.js';
import base from '../../config/base.js';
import orderdetailsService from '../../services/orderinfo.js'




Page({

  /**
   * 页面的初始数据
   */
  data: {
    icon_titlearrow: base.static + 'aftersale/titlearrow.png',
    icon_shopimg: base.static + 'aftersale/shopimg.png',
    icon_serviceimg1: base.static + 'aftersale/Bitmap.png',
    icon_serviceimg2: base.static + 'aftersale/thtk.png',
    service_arrowimg: base.static + 'aftersale/GroupCopy.png',
    list: {}
  },
  //去申请售后页面 仅退款
  goapplyfor1(){
    let orid = this.data.orid;
    Router.go('applyforsale', `orid=${orid}&saleafter_type=1`);
  },
  //去申请售后页面 退货退款
  goapplyfor2() {
    let orid = this.data.orid;
    Router.go('applyforsale', `orid=${orid}&saleafter_type=2`);
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    let orid = options.orid;
    that.setData({
      orid: orid
    })
    let param = {
      orid: options.orid
    }
    orderdetailsService.queryorderdetails(param, function (res) {
      if (res && res.code == 1) {
        let list = res.data,
        str_attr_val_name_obj = list.str_attr_val_name,
        str_attr_val_name = '';
        for (let k in str_attr_val_name_obj) {
          str_attr_val_name += k + ': ' + str_attr_val_name_obj[k] + ' ';
        }
        list.str_attr_val_name = str_attr_val_name; 
        that.setData({
          list: list
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },
})